#include "FiveWin.ch"

#define BAR_TOP         1
#define BAR_LEFT        2
#define BAR_RIGHT       3
#define BAR_DOWN        4
#define BAR_FLOAT       5

#ifdef __XPP__
   #define Super ::TWindow
#endif

memvar oIDE

//----------------------------------------------------------------------------//

function ResNew()

   ResOpen( "Resources: " )

return nil

//----------------------------------------------------------------------------//

function ResOpen( cResFile )

   local oWndRes := TWndRes():New( cResFile )

return nil

//----------------------------------------------------------------------------//

CLASS TWndRes FROM TWindow

   DATA   oBrw
   DATA   oTabs         // Resource Type Tab selector

   METHOD New( cTitle ) CONSTRUCTOR
   METHOD ReSize( nStype, nWidth, nHeight )

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( cTitle ) CLASS TWndRes

   local oFont

   Super:New(,,,, cTitle,,,, "Resource",, "N/W" )

   DEFINE BUTTONBAR ::oBar _3D SIZE 33, 33 OF Self

   DEFINE BUTTON RESOURCE "New" OF ::oBar ;
      MESSAGE "Add a new resource item" ;
      ACTION  ::Iconize()

   DEFINE BUTTON RESOURCE "Edit" OF ::oBar ;
      MESSAGE "Edit current resource item"

   DEFINE BUTTON RESOURCE "Del" OF ::oBar ;
      MESSAGE "Delete current resource item"

   DEFINE BUTTON RESOURCE "PrjAdd" GROUP OF ::oBar ;
      MESSAGE "Add these resources to a Project"

   SET MESSAGE OF Self TO "" NOINSET

   ::CoorsUpdate()

   @ ::nBottom - ::nTop - 43, 3 TABS ::oTabs ;
      PROMPTS "&Dialogs", "&Bitmaps", "&Icons", "&Cursors", "&Fonts", "&Version Control" ;
      OF Self SIZE ::nRight - ::nLeft, 18 PIXEL

   DEFINE FONT oFont NAME "Arial" SIZE 6, 15 BOLD

   @ 34, -1 LISTBOX ::oBrw FIELDS "", "" OF Self ;
      HEADERS "Name", "Description" ;
      SIZE ::nRight - ::nLeft, ::nBottom - ::nTop - 33 - 25 - 18 ;
      FONT oFont PIXEL

   ::Resize()

return nil

//----------------------------------------------------------------------------//

METHOD ReSize( nStype, nWidth, nHeight ) CLASS TWndRes

   local oRect

   oRect  = ::GetCliRect()

   oRect:nTop--
   oRect:nLeft--

   if ::oBar != nil
      do case
         case ::oBar:nMode == BAR_TOP
              oRect:nTop = ::oBar:nBtnHeight

         case ::oBar:nMode == BAR_LEFT
              oRect:nLeft += ( ::oBar:nBtnWidth - 1 ) + If( ::oBar:l3D, 4, 0 ) + 1

         case ::oBar:nMode == BAR_RIGHT
              oRect:nRight -= ( ::oBar:nBtnWidth + 1 ) + If( ::oBar:l3D, 3, 0 )

         case ::oBar:nMode == BAR_DOWN
              oRect:nBottom -= ( ::oBar:nBtnHeight + 2 )
      endcase
   endif

   oRect:nBottom -= 22

   if ::oMsgBar != nil
      oRect:nBottom -= ::oMsgBar:Height()
   endif

   ::oBrw:SetCoors( oRect )
   ::oBrw:Refresh()

   oRect:nTop = oRect:nBottom + 4
   oRect:nBottom += 21
   oRect:nRight++
   ::oTabs:SetCoors( oRect )
   ::oTabs:Refresh()

   ::oBar:Adjust()
   ::oMsgBar:Adjust()

return nil

//----------------------------------------------------------------------------//